package com.supreme.threadserver.threadpkg;

import java.util.concurrent.TimeUnit;

public class LoopThread implements Runnable {

    private final int loopCount;
    private final long timeout;

    public LoopThread(int loopCount, long timeout) {
        this.loopCount = loopCount;
        this.timeout = timeout;
    }

    @Override
    public void run() {
        final String threadName = Thread.currentThread().getName();
        System.out.println("threadName = " + threadName + " Start");

        for (int i = 0; i < this.loopCount; i++) {
            try {
                System.out.println("threadName = " + threadName + " loopCount = " + (i + 1));
                TimeUnit.MILLISECONDS.sleep(this.timeout);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

        System.out.println("threadName = " + threadName + " Finish");
    }
}
